﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

using WeChatDemo.Utils;
using WeChatDemo.Models.Photo;

namespace WeChatDemo.DataProvider.Photo
{
    public class DAOPhotoUser : DAOBase
    {
        public static bool Add(PhotoUser model)
        {
            bool flag = false;

            string _sqlString = $"INSERT INTO [PhotoUser](ID, UserName, Mobile, Orginazation, WechatOpenId, RoleID) VALUES('{model.ID}','{model.UserName}', '{model.Mobile}', '{model.Orginazation}', '{model.WechatOpenId}', {model.RoleID})";

            flag = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, _sqlString) == 0 ? false : true;

            return flag;
        }

        public static bool Update(PhotoUser model)
        {
            bool flag = false;

            string _sqlString = $"UPDATE [PhotoUser] SET UserName = '{model.UserName}', Mobile = '{model.Mobile}', Orginazation = '{model.Orginazation}', WechatOpenId = '{model.WechatOpenId}', RoleID = {model.RoleID} WHERE ID = '{model.ID}'";

            flag = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.Text, _sqlString) == 0 ? false : true;

            return flag;
        }
    }
}